package my.jieh.tips.swing.order;

import javax.swing.*;
import java.util.*;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: Blueimp</p>
 * @author jieh
 * @version 1.0
 */

public class AlphaOrder implements Comparator {
  public int compare(Object one, Object two) {
    if (! (one instanceof JButton)) return 1;
    if (! (two instanceof JButton)) return 1;
    JButton button1 = (JButton)one;
    JButton button2 = (JButton)two;
    String text1 = button1.getText();
    String text2 = button2.getText();
    return text1.compareTo(text2);
  }
}

